{extend name="public/base"}

{block name="main"}
<div class="layui-card">
    <blockquote class="layui-elem-quote">品牌：{$brand.name}</blockquote>
    <form class="layui-form" action="">
        {volist name="categorys" id="vo"}
        {notempty name="$vo.childrens"}

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>{$vo.name}</legend>
        </fieldset>


        <div class="layui-form-item">
            <div class="layui-block" style="padding-left: 20px;">
                {volist name="vo.childrens" id="v"}
                <input type="checkbox" name="ids[]" value="{$v.id}" title="{$v.name}" {in name="v.id" value="$brand_category"} checked {/in}>
                {/volist}
            </div>
        </div>
        <hr>
        {/notempty}
        {/volist}
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-footer" style="left: 0;">
                    <input type="hidden" name="id" value="{$brand.id|default=0}">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即提交</button>
                </div>
            </div>
        </div>
    </form>
</div>
{/block}

{block name="js"}
<script>

    layui.config({
        base: '/layui_admin/src/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'laydate', 'form'], function () {
        let admin = layui.admin, form = layui.form;
        /* 监听提交 */
        form.on('submit(component-form-demo1)', function (data) {
            layer.load();

            //请求登入接口
            admin.req({
                url: "{:url('relevance_category')}" //实际使用请改成服务端真实接口
                ,type : 'post'
                ,data: data.field
                ,done: function(res){
                    //登入成功的提示与跳转
                    layer.msg('保存成功', {
                        offset: '15px'
                        ,icon: 1
                        ,time: 1000
                    }, function(){
                        parent.location.reload(); //刷新页面
                    });
                }
            });
            return false;
        });
    });
</script>
{/block}